<?php

namespace app\admin\controller;
use app\admin\controller\Base;
use think\Loader;
use think\Db;
use \com\Api4SmMs;
use QL\QueryList;
use think\Controller;
class Tool extends Controller
{
    //获取QQ头像
    public function head()
    {
        if (request()->isPost()){
            $qq = input('param.qq/d');
            if(!$qq || !preg_match('|^[1-9]\d{4,10}$|i',$qq)){
                return json(array('code'=>0,'msg'=>'QQ格式错误'));
            }
            $nickname = file_get_contents('http://users.qzone.qq.com/fcg-bin/cgi_get_portrait.fcg?uins='.$qq);
            $image = 'http://q.qlogo.cn/headimg_dl?dst_uin='.$qq.'&spec=100';

            if(strstr($nickname,'portraitCallBack')){
                return json(array('code'=>1,'msg'=>'成功','image'=>$image,'data'=>isset(json_decode(trim(mb_convert_encoding($nickname, "UTF-8", "GBK"),'portraitCallBack()'),true)[$qq][6])?json_decode(trim(mb_convert_encoding($nickname, "UTF-8", "GBK"),'portraitCallBack()'),true)[$qq][6]:'游客'));
            }else if(strstr($nickname,'_Callback')){
                return json(array('code'=>0,'msg'=>'获取昵称失败'));
            }
            return json(array('code'=>0,'msg'=>'获取昵称失败'));
        }
        return $this->fetch();
    }
    //excel导入导出模板展示
    public function excel()
    {
        $data = Db::name('student')->select();
        $this->assign('data',$data);
        return $this->fetch();
    }
    //导出功能实现
    public function daochu(){
        $xlsData = Db('student')->select();
        Vendor('PHPExcel.PHPExcel');//调用类库,路径是基于vendor文件夹的
        Vendor('PHPExcel.PHPExcel.Worksheet.Drawing');
        Vendor('PHPExcel.PHPExcel.Writer.Excel2007');
        $objExcel = new \PHPExcel();
        //set document Property
        $objWriter = \PHPExcel_IOFactory::createWriter($objExcel, 'Excel5');
        $objActSheet = $objExcel->getActiveSheet();
        $objActSheet ->setTitle("demo");//可以给sheet设置名称为"demo"
        $key = ord("A");
        $letter =explode(',',"A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z");
        $arrHeader = array('序号','姓名','性别','电话','邮箱','班型1','班型2','身份证号','考区','实付款','大写金额','纸质合同','纸质发票','发票类型','发票抬头','纳税识别号','公司名称','公司电话','开户行名称','对公账号','邮寄地址','备注','填写时间');
        //填充表头信息
        $lenth =  count($arrHeader);
        for($i = 0;$i < $lenth;$i++) {
            $objActSheet->setCellValue("$letter[$i]1","$arrHeader[$i]");
        };
        //填充表格信息
        foreach($xlsData as $k=>$v){
            switch ($v['banxing1'])
            {
                case 0:
                    $v['banxing1'] = "工商企业管理专科名校精品班";
                    break;
                case 1:
                    $v['banxing1'] = "工商企业管理本科名校精品班";
                    break;
                case 2:
                    $v['banxing1'] = "工商企业管理名校精品直本班";
                    break;
                case 3:
                    $v['banxing1'] = "工商企业管理专科VIP直通班";
                    break;
                case 4:
                    $v['banxing1'] = "工商企业管理本科VIP直通班";
                    break;

                default:
                    echo "其他";
            }
            switch ($v['banxing2'])
            {
                case 0:
                    $v['banxing2'] = "工商企业管理专科名校精品班";
                    break;
                case 1:
                    $v['banxing2'] = "工商企业管理本科名校精品班";
                    break;
                case 2:
                    $v['banxing2'] = "工商企业管理名校精品直本班";
                    break;
                case 3:
                    $v['banxing2'] = "工商企业管理专科VIP直通班";
                    break;
                case 4:
                    $v['banxing2'] = "工商企业管理本科VIP直通班";
                    break;

                default:
                    echo "其他";
            }
            switch ($v['kaoqu'])
            {
                case 0:
                    $v['kaoqu'] = "黑龙江";
                    break;
                case 1:
                    $v['kaoqu'] = "内蒙古";
                    break;
                case 2:
                    $v['kaoqu'] = "新疆";
                    break;
                case 3:
                    $v['kaoqu'] = "西藏";
                    break;
                case 4:
                    $v['kaoqu'] = "宁夏";
                    break;
                default:
                    echo "其他";
            }
            $k +=2;
            $objActSheet->setCellValue('A'.$k,$k-1);
            $objActSheet->setCellValue('B'.$k, $v['xingming']);
            $objActSheet->setCellValue('C'.$k,$v['xingbie'] == 0?'男':'女');
            $objActSheet->setCellValue('D'.$k, $v['dianhua']);
            $objActSheet->setCellValue('E'.$k, $v['youxiang']);
            $objActSheet->setCellValue('F'.$k,$v['banxing1']);
            $objActSheet->setCellValue('G'.$k, $v['banxing2']);
            $objActSheet->setCellValue('H'.$k, $v['shenfenzheng']);
            $objActSheet->setCellValue('I'.$k, $v['kaoqu']);
            $objActSheet->setCellValue('J'.$k, $v['shifukuan']);
            $objActSheet->setCellValue('K'.$k, $v['daxiejine']);
            $objActSheet->setCellValue('L'.$k, $v['zhizhihetong'] == 0?'有':'无');
            $objActSheet->setCellValue('M'.$k, $v['zhizhifapiao'] == 0?'有':'无');
            $objActSheet->setCellValue('N'.$k, $v['fapiaoleixing']);
            $objActSheet->setCellValue('N'.$k, $v['fapiaoleixing'] == 0?'专票':'普票');
            $objActSheet->setCellValue('O'.$k, $v['taitou'] == 0?'个人':'公司');
            $objActSheet->setCellValue('P'.$k, $v['shibiehao']);
            $objActSheet->setCellValue('Q'.$k, $v['gongsimingcheng']);
            $objActSheet->setCellValue('R'.$k, $v['gongsidianhua']);
            $objActSheet->setCellValue('S'.$k, $v['duigongming']);
            $objActSheet->setCellValue('T'.$k, $v['duigongzhanghao']);
            $objActSheet->setCellValue('U'.$k, $v['youjidizhi']);
            $objActSheet->setCellValue('V'.$k, $v['beizhu']);
            $objActSheet->setCellValue('W'.$k, date('Y-m-d h:i:s',$v['create_time']));

            // 表格高度
            $objActSheet->getRowDimension($k)->setRowHeight(20);
        }

        $width = array(10,15,20,25,30);
        //设置表格的宽度
        $objActSheet->getColumnDimension('A')->setWidth($width[1]);
        $objActSheet->getColumnDimension('B')->setWidth($width[2]);
        $objActSheet->getColumnDimension('C')->setWidth($width[3]);
        $objActSheet->getColumnDimension('D')->setWidth($width[4]);
        $objActSheet->getColumnDimension('E')->setWidth($width[1]);
        $objActSheet->getColumnDimension('F')->setWidth($width[1]);
        $objActSheet->getColumnDimension('G')->setWidth($width[1]);
        $objActSheet->getColumnDimension('H')->setWidth($width[1]);
        $objActSheet->getColumnDimension('I')->setWidth($width[1]);
        $outfile = "学员信息列表.xls";
        ob_end_clean();
        header("Content-Type: application/force-download");
        header("Content-Type: application/octet-stream");
        header("Content-Type: application/download");
        header('Content-Disposition:inline;filename="'.$outfile.'"');
        header("Content-Transfer-Encoding: binary");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Pragma: no-cache");
        $objWriter->save('php://output');
    }
    //导入功能实现
    public function daoru(){
        if(request()->isPost()) {
            Vendor('PHPExcel.PHPExcel');//调用类库,路径是基于vendor文件夹的
            Vendor('PHPExcel.PHPExcel.PHPExcel_IOFactory');
            Vendor('PHPExcel.PHPExcel.PHPExcel_Cell');
            //实例化PHPExcel
            $objPHPExcel = new \PHPExcel();
            $file = request()->file('file');
            if ($file) {
                $file_types = explode(".", $_FILES ['file'] ['name']); // ["name"] => string(25) "excel文件名.xls"
                $file_type = $file_types [count($file_types) - 1];//xls后缀
                $file_name = $file_types [count($file_types) - 2];//xls去后缀的文件名
                /*判别是不是.xls文件，判别是不是excel文件*/
                if (strtolower($file_type) != "xls" && strtolower($file_type) != "xlsx") {
                    echo '不是Excel文件，重新上传';
                    die;
                }

                $info = $file->move(ROOT_PATH . 'public/uploads' . DS . 'excel');//上传位置
                $path = ROOT_PATH . 'public/uploads' . DS . 'excel' . DS;
                $file_path = $path . $info->getSaveName();//上传后的EXCEL路径
                //echo $file_path;exit;//文件路径exit;
                $exfn = $this->_readExcel($file_path);
                //dump($exfn);exit;
                array_splice($exfn, 1, 0);
                unset($exfn[0]);
                //dump($exfn);exit;//查看数组


                /*将数组的键改为自定义名称*/
                $keys = array('xingming','xingbie','dianhua','youxiang','banxing1','banxing2','shenfenzheng','kaoqu','shifukuan','daxiejine','zhizhihetong','zhizhifapiao','fapiaoleixing','taitou','shibiehao','gongsimingcheng','gongsidianhua','duigongming','duigongzhanghao','youjidizhi','beizhu','create_time');
                foreach ($exfn as $i => $vals) {
                    $exfn[$i] = array_combine($keys, $vals);
                }
                //遍历数组写入数据库
                for ($i = 1; $i <= count($exfn); $i++) {
                    switch ($exfn[$i]['banxing1'])
                    {
                        case '工商企业管理专科名校精品班':
                            $exfn[$i]['banxing1'] = 0;
                            break;
                        case '工商企业管理本科名校精品班':
                            $exfn[$i]['banxing1'] = 1;
                            break;
                        case '工商企业管理名校精品直本班':
                            $exfn[$i]['banxing1'] = 2;
                            break;
                        case '工商企业管理专科VIP直通班':
                            $exfn[$i]['banxing1'] = 3;
                            break;
                        case '工商企业管理本科VIP直通班':
                            $exfn[$i]['banxing1'] = 4;
                            break;
                    }
                    switch ($exfn[$i]['banxing2'])
                    {
                        case '工商企业管理专科名校精品班':
                            $exfn[$i]['banxing2'] = 0;
                            break;
                        case '工商企业管理本科名校精品班':
                            $exfn[$i]['banxing2'] = 1;
                            break;
                        case '工商企业管理名校精品直本班':
                            $exfn[$i]['banxing2'] = 2;
                            break;
                        case '工商企业管理专科VIP直通班':
                            $exfn[$i]['banxing2'] = 3;
                            break;
                        case '工商企业管理本科VIP直通班':
                            $exfn[$i]['banxing2'] = 4;
                            break;
                    }
                    switch ($exfn[$i]['kaoqu'])
                    {
                        case '黑龙江':
                            $exfn[$i]['kaoqu'] = 0;
                            break;
                        case '内蒙古':
                            $exfn[$i]['kaoqu'] = 1;
                            break;
                        case '新疆':
                            $exfn[$i]['kaoqu'] = 2;
                            break;
                        case '西藏':
                            $exfn[$i]['kaoqu'] = 3;
                            break;
                        case '宁夏':
                            $exfn[$i]['kaoqu'] = 4;
                            break;
                    }
                    if($exfn[$i]['xingbie'] == '男'){
                        $exfn[$i]['xingbie'] = '0';
                    }else{
                        $exfn[$i]['xingbie'] = '1';
                    }

                    if($exfn[$i]['zhizhihetong'] == '有'){
                        $exfn[$i]['zhizhihetong'] = '0';
                    }else{
                        $exfn[$i]['zhizhihetong'] = '1';
                    }

                    if($exfn[$i]['zhizhifapiao'] == '有'){
                        $exfn[$i]['zhizhifapiao'] = '0';
                    }else{
                        $exfn[$i]['zhizhifapiao'] = '1';
                    }

                    if($exfn[$i]['fapiaoleixing'] == '专票'){
                        $exfn[$i]['fapiaoleixing'] = '0';
                    }else{
                        $exfn[$i]['fapiaoleixing'] = '1';
                    }

                    if($exfn[$i]['taitou'] == '个人'){
                        $exfn[$i]['taitou'] = '0';
                    }else{
                        $exfn[$i]['taitou'] = '1';
                    }
                    $data = $exfn[$i];
                    $data['create_time'] = strtotime($exfn[$i]['create_time']);
                    $res = Db::name('student')->insert($data);
                }
                if(false === $res)
                {
                    return json(['code' => -1, 'url' => 'Tool/excel', 'msg' => 'Excel导入数据库失败，请稍后重试。']);
                }else{
                    return json(['code' => 1, 'url' => 'Tool/excel', 'msg' => '导入成功！']);
                }
            }
        }
    }
    //创建一个读取excel数据，可用于入库
    public function _readExcel($path)
    {
        Vendor('PHPExcel.PHPExcel');//调用类库,路径是基于vendor文件夹的
        Vendor('PHPExcel.PHPExcel.PHPExcel_IOFactory');
        $xlsReader = \PHPExcel_IOFactory::createReader('Excel2007');
        if(!$xlsReader->canRead($path)){
            $xlsReader = \PHPExcel_IOFactory::createReader('Excel5');
        }
        $objPHPExcel = $xlsReader->load($path,$encode='utf-8');
        $xlsReader->setReadDataOnly(true);
        $xlsReader->setLoadSheetsOnly(true);
        $Sheets = $xlsReader->load($path);
        //开始读取上传到服务器中的Excel文件，返回一个二维数组
        $dataArray = $Sheets->getSheet(0)->toArray();
        return $dataArray;
    }
    //蓝奏VIP直链解析
    public function lanzhou()
    {
        if(request()->isAjax()){
            $url = input('get.url');
            $ruleMatchDetailInList = "~ifr2\"\sname=\"[\s\S]*?\"\ssrc=\"\/(.*?)\"~";
            $aa = preg_match($ruleMatchDetailInList, $this->MloocCurl($url,null,null,null),$link);
            if(empty($link[1])){
                return json(['code' => -2, 'url' => 'Tool/lanzhou', 'msg' => '链接不存在，请检查后重新输入']);
            }
            $ifurl = "https://www.lanzous.com/".$link[1];
            $ruleMatchDetailInList = "~=\s'(.*?)';[\S\s]*?=\s'(.*?)'[\S\s]*?=\s'(.*?)'[\S\s]*?=\s'(.*?)'~";
            preg_match($ruleMatchDetailInList, $this->MloocCurl($ifurl,null,null,null),$segment);
            #第三步
            #post提交的数据
            $post_data = array(
                "action" => $segment[1],
                "file_id" => $segment[2],
                "t" => $segment[3],
                "k" => $segment[4]
            );
            $obj = json_decode($this->MloocCurl("https://www.lanzous.com/ajaxm.php","post",$ifurl,$post_data));#json解析
            if ($obj->dom == "") {#判断链接是否正确
                return json(['code' => -1, 'url' => 'Tool/lanzhou', 'msg' => '链接输入错误，请重新输入']);
            }else{
                $downUrl = $obj->dom."/file/".$obj->url;
                return json(['code' => 1, 'url' => 'Tool/lanzhou', 'msg' => '获取成功','vip_url'=>$downUrl]);
            }

        }
        return $this->fetch();
    }
    //curl请求
    public function MloocCurl($url,$method,$ifurl,$post_data){
        $UserAgent = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36';#设置ua
        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        if ($method == "post") {
            curl_setopt($curl, CURLOPT_REFERER, $ifurl);
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $post_data);
        }
        $response = curl_exec($curl);
        curl_close($curl);
        return $response;
    }
    //抖音视频解析去水印
    public function douyin(){
        if(request()->isAjax()){
            $url = input('get.url');
//            dump($url);exit;
            $UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_HEADER, 0);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
            curl_setopt($curl, CURLOPT_ENCODING, '');
            curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
            curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
            $data = curl_exec($curl);
            curl_close($curl);
            //获取
            preg_match_all('#playwm\/\?video_id=(.*?)&line=0#' , $data ,$url);
            preg_match_all('#<p class="desc">(.*?)<\/p>#' , $data ,$name);
            //正则匹配
            if (empty($url[1][0])) {
                //echo '请输入正确网址，格式为：http://'.$_SERVER['HTTP_HOST'] . '/douyin.php?url=视频地址';
                return json(['code' => -1, 'url' => '','msg' => '请检查网址是否正确']);
            }else{
                return json(['code' => 1, 'url' => 'https://aweme.snssdk.com/aweme/v1/play/?video_id='.$url[1][0],'name'=>$name[1][0], 'msg' => '解析并去水印成功']);
            }
        }
        return $this->fetch();
    }
    //m3u8格式视频解析
    public function m3u8(){
        if(request()->isAjax())
        {
            $url = input('get.url');
            $new_url = "f=http://". $_SERVER['HTTP_HOST']. "/static/admin/my/flash/m3u8.swf&a=".$url;
            if(!empty($url)){
                return json(['code' => 1, 'url' => $new_url,'msg' => '解析成功']);
            }else{
                return json(['code' => -1, 'url' => '','msg' => '请检查网址是否正确']);
            }
        }
        return $this->fetch();
    }
    //图片外链 对接  https://sm.ms/
    public function pic()
    {
        return $this->fetch();
    }
    public function pic_uploads()
    {
        if(request()->isAjax())
        {
            $pic = request()->file('file');
            if($pic){
                $info = $pic->move(ROOT_PATH . 'public' . DS . 'uploads/pic');//用户上传到sm.ms 需要先本地保存下
                $getSaveName = $info->getSaveName();
                $a=new \com\Smms();
                $r=$a->upload(ROOT_PATH . 'public' . DS . 'uploads/pic/' . $getSaveName);//调用upload方法，传入文件路径
                $file = ROOT_PATH . 'public' . DS . 'uploads/pic/' . $getSaveName;//文件信息
                if($r['code'] == 'success'){
                    //unlink($file);//删除本地文件
                    return json(['code' => 1, 'data' =>$r['data'],'msg' => '上传成功']);

                }else{
                    return json(['code' => -1, 'data' =>$r['data'],'msg' => 'No files were uploaded.']);
                }
            }
        }else{
            return json(['code' => -2, 'msg' => '您还未上传图片']);
        }
    }
    /*
     * 采集视频
     * 对接电影天堂  http://www.dytt8.net
     * http://www.dytt8.net/html/gndy/dyzz/index.html  最新电影
     * http://www.dytt8.net/html/tv/hytv/   华语电视剧
     * http://www.dytt8.net/html/tv/rihantv/index.html   日韩电视剧
     * http://www.dytt8.net/html/tv/oumeitv/index.html   欧美电视剧
     * http://www.dytt8.net/html/newgame/index.html   游戏
     * http://www.dytt8.net/html/zongyi2013/index.html   综艺节目
     * http://www.dytt8.net/html/dongman/index.html   动漫
     */
    public function caijimovie(){
        //获取列表的标题、链接、描述匹配·
        $rules = [
            'title' => array('b>.ulink','text'),
            'link' => array('b>.ulink','href'),
            'dec' => array(".co_content8 tr:last-child(colspan='2')","text"),
        ];
        //最新电影
        for($i = 1;$i<=5;$i++){
            $url1 = 'http://www.dytt8.net/html/gndy/dyzz/list_23_' . $i .".html";
            //dump($url);
            $html = @file_get_contents($url1);
            $zxdy = QueryList::html($html)
                ->encoding('UTF-8','GB2312')
                ->rules($rules)
                ->query()
                ->getData()
                ->all();
            $zxdyall[$i]=$zxdy;
            $this->assign('zxdy',$zxdyall);
        }
        //华语电视剧
        for($i = 1;$i<=5;$i++){
            $url2 = 'http://www.dytt8.net/html/tv/hytv/list_71_' . $i .".html";
            //dump($url);
            $html = @file_get_contents($url2);
            $hydsj = QueryList::html($html)
                ->encoding('UTF-8','GB2312')
                ->rules($rules)
                ->query()
                ->getData()
                ->all();
            $hydsjall[$i]=$hydsj;
            $this->assign('hydsj',$hydsjall);
        }
        //日韩电视剧
        for($i = 1;$i<=5;$i++){
            $url3 = 'http://www.dytt8.net/html/tv/rihantv/list_8_' . $i .".html";
            //dump($url);
            $html = @file_get_contents($url3);
            $rhdsj = QueryList::html($html)
                ->encoding('UTF-8','GB2312')
                ->rules($rules)
                ->query()
                ->getData()
                ->all();
            $rhdsjall[$i]=$rhdsj;
            //dump($rhdsjall[$i]);
            $this->assign('rhdsj',$rhdsjall);
        }
        //欧美电视剧
        for($i = 1;$i<=5;$i++){
            $url4 = 'http://www.dytt8.net/html/tv/oumeitv/list_9_' . $i .".html";
            //dump($url);
            $html = @file_get_contents($url4);
            $omdsj = QueryList::html($html)
                ->encoding('UTF-8','GB2312')
                ->rules($rules)
                ->query()
                ->getData()
                ->all();
            $omdsjall[$i]=$omdsj;
            $this->assign('omdsj',$omdsjall);
        }
        //游戏
        for($i = 1;$i<=5;$i++){
            $url5 = 'http://www.dytt8.net/html/newgame/list_105_' . $i .".html";
            //dump($url);
            $html = @file_get_contents($url5);
            $yx = QueryList::html($html)
                ->encoding('UTF-8','GB2312')
                ->rules($rules)
                ->query()
                ->getData()
                ->all();
            $yxall[$i]=$yx;
            $this->assign('yx',$yxall);
        }
        //综艺节目
        for ($i = 1; $i <= 5; $i++) {
            $url6 = @file_get_contents('http://www.dytt8.net/html/zongyi2013/list_99_' . $i . '.html');
            $zyjm = QueryList::html($url6)
                ->encoding('UTF-8', 'GB2312')
                ->rules([
                    'title' => ['.ulink:last-child', 'text'],
                    'link' => ['.ulink:last-child', 'href'],
                    'dec' => [".co_content8 tr:last-child td", "text"],
                ])
                ->query()
                ->getData()
                ->all();
            $zyjmAll[$i] = $zyjm;
            $this->assign('zyjm',$zyjmAll);
        }
        //动漫
        for ($i = 1; $i <= 5; $i++) {
            $url7 = @file_get_contents('http://www.dytt8.net/html/dongman/list_16_' . $i . '.html');
            $dm = QueryList::html($url7)
                ->encoding('UTF-8', 'GB2312')
                ->rules([
                    'title' => ['.ulink:last-child', 'text'],
                    'link' => ['.ulink:last-child', 'href'],
                    'dec' => [".co_content8 tr:last-child td", "text"],
                ])
                ->query()
                ->getData()
                ->all();
            $dmAll[$i] = $dm;
            $this->assign('dm',$dmAll);
        }
        $html = $this->fetch();
        $data = file_put_contents(ROOT_PATH ."/application/admin/view/movie.html",$html);
        if(false === $data){
            return json(['code' => -1, 'msg' => '生成失败']);
        }else{
            return json(['code' => 1, 'msg' => '生成成功']);
        }
    }
    //展示
    public function movie(){
        return $this->fetch('./movie');
    }
    //文章详情页
    public function caijiarticle()
    {
        if(request()->isGet()){
            $rules = [
                'title' => array('.title_all>h1','text'),
                'content' => array('.co_content8 div:last-child(2)','html'),
            ];
            //采集文章详情页
            $art = QueryList::get("http://www.dytt8.net" . input('get.link'))
                ->encoding('UTF-8','GB2312')
                ->rules($rules)
                ->query()
                ->getData()
                ->all();
            foreach ($art as $m) {
                $m['title'];
                $m['content'];
            }
        }
        $this->assign('m',$m);
        return $this->fetch();
    }
}